import os.path
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
# file = 'file:///' + os.path.abspath('html/popup.html')
file = os.path.join(os.path.abspath('html/popup.html'))
driver.get(file)
driver.maximize_window()

btn = driver.find_elements(By.TAG_NAME, 'button')  # 获取到的是列表
# btn[0].click()
# time.sleep(2)
# alert = driver.switch_to.alert
# alert.accept()
#
# btn[1].click()
# time.sleep(2)
# alert = driver.switch_to.alert
# alert.dismiss()

btn[2].click()
time.sleep(2)
alert = driver.switch_to.alert
print(alert.text)
alert.send_keys('123456')

time.sleep(3)
driver.quit()
